//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows;

namespace OpenLS.Spreadsheet.UI
{
    class InternalDragEventArgs: BaseDragEventArgs
    {
        // Fields
        private readonly DragDropEffects _allowedEffects;
        private readonly InternalDataObject _data;
        private readonly DragDropKeyStates _dragDropKeyStates;
        private readonly Point _dropPoint;
        private DragDropEffects _effects;
        private readonly DependencyObject _target;

        // Methods
        internal InternalDragEventArgs(
            RoutedEvent evnt, InternalDataObject data, DragDropKeyStates dragDropKeyStates, 
            DragDropEffects allowedEffects, DependencyObject target, Point point): base(evnt)
        {
            //        DragDrop.IsValidDragDropKeyStates(dragDropKeyStates);
            //      DragDrop.IsValidDragDropEffects(allowedEffects);
            _data = data;
            _dragDropKeyStates = dragDropKeyStates;
            _allowedEffects = allowedEffects;
            _target = target;
            _dropPoint = point;
            _effects = allowedEffects;
        }

        public  override Point GetPosition(IInputElement relativeTo)
        {
            if (relativeTo == null)
            {
                throw new ArgumentNullException("relativeTo");
            }
            Point point = new Point(0.0, 0.0);
            if (_target != null)
            {
                if (_target == relativeTo)
                    return _dropPoint;
                throw new NotImplementedException();//\\point = InputElement.TranslatePoint(this._dropPoint, this._target, (DependencyObject) relativeTo));
            }
            return point;
        }

        protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget)
        {
            InternalDragEventHandler handler = (InternalDragEventHandler)genericHandler;
            handler(genericTarget, this);
        }

        // Properties
        public override  DragDropEffects AllowedEffects
        {
            get
            {
                return _allowedEffects;
            }
        }

        public InternalDataObject Data
        {
            get
            {
                return _data;
            }
        }

        public override DragDropEffects Effects
        {
            get
            {
                return _effects;
            }
            set
            {
                _effects = value;
            }
        }

        public override DragDropKeyStates KeyStates
        {
            get
            {
                return _dragDropKeyStates;
            }
        }

        public override object GetData(string format)
        {
            return this._data.GetData(format);
        }

        public override bool GetDataPresent(string format)
        {
            return Data.GetDataPresent(format);
        }
    }
}
